﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using DynamicMVVM.Demo.UI.Views;

namespace DynamicMVVM.Demo.UI.ViewModels
{
    public class MainViewModel  : DynamicViewModel
    {
        public MainViewModel()
        {
            StatusViewModel = new StatusViewModel
                                  {
                                      StatusMessage = "Loaded"
                                  };

            DisplayedControl = new HomeView();

            var fileMenu = new MenuItemViewModel(){ Header = "File"};
            
            fileMenu.Items.Add(new MenuItemViewModel() {Header = "Exit"});

            var editMenu = new MenuItemViewModel() {Header = "Edit"};

            MenuItems = new ObservableCollection<MenuItemViewModel>
                            {
                                fileMenu,
                                editMenu
                            };
        }

        private object _displayedControl;

        public object DisplayedControl
        {
            get { return _displayedControl; }
            set
            {
                _displayedControl = value;
                RaisePropertyChanged(() => DisplayedControl);
            }
        }

        public ObservableCollection<MenuItemViewModel> MenuItems { get; set; }

        #region StatusViewModel

        private StatusViewModel _statusViewModel;

        public StatusViewModel StatusViewModel
        {
            get { return _statusViewModel; }
            set
            {
                _statusViewModel = value;
                RaisePropertyChanged(() => StatusViewModel);
            }
        }

        #endregion

    }

    public class MenuItemViewModel
    {
        public MenuItemViewModel()
        {
            Items = new List<MenuItemViewModel>();
        }
        public string Header { get; set; }

        public IList<MenuItemViewModel> Items { get; set; }
    }
}
